<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>
        <ui:composition template="./../../Template/generalTemplate.xhtml">
            <ui:define name="content">
                <p:panel id="supplierMgt" header="Create Raw Material Purchasing Order" style="height:495px;">
                    <div style="margin-top:20px;margin-left:10px;margin-right:10px;">
                        <h:form id="form">
                            <f:view beforePhase="#{createNewPurchasingOrderManagedBean.initView}">
                                <p:growl id="msgs" showDetail="true" /> 
                                <p:dataTable var="car" value="#{createNewPurchasingOrderManagedBean.rawMaterialRequirementList}" id="list">  


                                    <p:column headerText="Raw Material"  >  
                                        <h:outputText value="#{list.rawMaterial.rawMaterialName}" />  
                                    </p:column>  

                                    <p:column headerText="Select a Supplier"  >  
                                        <p:commandButton update="select" oncomplete="supplierDialog.show()"  
                                                         image="ui-icon ui-icon-circle-triangle-e">  
                                            <f:setPropertyActionListener value="#{list}"  target="#{createNewPurchasingOrderManagedBean.selectedRawMaterialRequirement}" />  
                                        </p:commandButton>  
                                    </p:column>  

                                    <p:column headerText="Required Quantity"  >  
                                        <h:outputText value="#{list.rawMaterial.rawMaterialName}" />  
                                    </p:column>  

                                    <p:column headerText="Options">  
                                        <p:rowEditor />  
                                    </p:column>  

                                </p:dataTable> 
                                <p:dialog header="Car Detail" widgetVar="supplierDialog" resizable="false" width="200" showEffect="explode" hideEffect="explode">  
                                    <p:dataTable id="display" selection="#{createNewPurchasingOrderManagedBean.selectedSupplierLineItem}" value="#{createNewPurchasingOrderManagedBean.selectedRawMaterialRequirement.rawMaterial.supplierLineItemList}" var="supplierLineItemList" >  
                                        <p:column selectionMode="single" />  

                                        <p:column headerText="Supplier">  
                                        <h:outputText value="#{supplierLineItemList.supplier.supplierName}" />  
                                        </p:column>
                                        
                                        <p:column headerText="Price Offer">  
                                        <h:outputText value="#{supplierLineItemList.price}" />  
                                        </p:column>
                                        
                                    </p:dataTable>  
                                    <p:commandButton actionListener ="#{createNewPurchasingOrderManagedBean.confirmSupplierLineItem}"  value="Confirm"   /> 
                                </p:dialog>  
                            </f:view>
                        </h:form>  
                    </div>
                </p:panel>
            </ui:define>
        </ui:composition>
    </body>
</html>